package com.yzt.rabbitmq.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitConfig {

	public static String DEFAULT_QUEUE = "DEFAULT_QUEUE";

	public static String DEFAULT_EXCHANGE = "DEFAULT_EXCHANGE";

	@Bean
	public Queue defaultQueue() {
		return new Queue(DEFAULT_QUEUE);
	}

	@Bean
	public FanoutExchange fanoutExchange() {
		return new FanoutExchange(DEFAULT_EXCHANGE);
	}

	@Bean
	public Binding bingDefault(Queue defaultQueue, FanoutExchange fanoutExchange) {
		return BindingBuilder.bind(defaultQueue).to(fanoutExchange);
	}
}
